package com.jieshuibao.service;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.jieshuibao.mapper.CmsArticleMapper;
import com.jieshuibao.mapper.CmsCategoryMapper;
import com.jieshuibao.model.db.CmsArticle;
import com.jieshuibao.model.db.CmsArticleExample;
import com.jieshuibao.model.db.CmsCategory;

@Service
public class CmsArticleService{
	
	@Resource
	private CmsArticleMapper cmsArticleMapper;
	@Resource
	private CmsCategoryMapper cmsCategoryMapper; 
	
	public void addCmsArticle(CmsArticle cmsArticle) {
		cmsArticleMapper.insertSelective(cmsArticle);
	}
	
	public void delCmsArticleById(String id) {
		cmsArticleMapper.deleteByPrimaryKey(id);
	}
	
	public void updateCmsArticle(CmsArticle cmsArticle) {
		cmsArticleMapper.updateByPrimaryKeySelective(cmsArticle);
	}
	
	public CmsArticle getCmsArticleById(String id) {
		return cmsArticleMapper.selectByPrimaryKey(id);
	}
	
	public List<CmsArticle> getPageCmsArticle(CmsArticleExample cmsArticleExample) {
		return cmsArticleMapper.selectPage(cmsArticleExample);
	}
	
	public int countCmsArticle(CmsArticleExample cmsArticleExample) {
		return cmsArticleMapper.countByExample(cmsArticleExample);
	}
	
	public CmsCategory getCmsCategoryById(String id){
		return cmsCategoryMapper.selectByPrimaryKey(id);
	}
}
